﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Miao.UI
{
    public class UIEventListener : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler, IPointerUpHandler, IPointerClickHandler
    {
        public event Action<PointerEventData> OnDragHandler;
        public event Action<PointerEventData> OnEndDragHandler;
        public event Action<PointerEventData> OnBeginDragHandler;

        public event Action<PointerEventData> OnPointerUpHandler;
        public event Action<PointerEventData> OnPointerExitHandler;
        public event Action<PointerEventData> OnPointerClickHandler;
        public event Action<PointerEventData> OnPointerEnterHandler;
        public event Action<PointerEventData> OnPointerDownHandler;

        public void OnDrag(PointerEventData eventData)
        {
            OnDragHandler?.Invoke(eventData);
        }
        public void OnEndDrag(PointerEventData eventData)
        {
            OnEndDragHandler?.Invoke(eventData);
        }
        public void OnBeginDrag(PointerEventData eventData)
        {
            OnBeginDragHandler?.Invoke(eventData);
        }

        public void OnPointerUp(PointerEventData eventData)
        {
            OnPointerUpHandler?.Invoke(eventData);
        }
        public void OnPointerExit(PointerEventData eventData)
        {
            OnPointerExitHandler?.Invoke(eventData);
        }
        public void OnPointerClick(PointerEventData eventData)
        {
            OnPointerClickHandler?.Invoke(eventData);
        }
        public void OnPointerEnter(PointerEventData eventData)
        {
            OnPointerEnterHandler?.Invoke(eventData);
        }
        public void OnPointerDown(PointerEventData eventData)
        {
            OnPointerDownHandler?.Invoke(eventData);
        }
    }
}